home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / C-D / DeveloperStax.cpt / Developer Stack 1.1 / card_11574.txt < prev    next >
Text File  |  1989-02-26  |  3KB  |  130 lines

  1. -- card: 11574 from stack: in.1
  2. -- bmap block id: 0
  3. -- flags: 4000
  4. -- background id: 3837
  5. -- name: RenameFile
  6.  
  7.  
  8. -- part 1 (button)
  9. -- low flags: 00
  10. -- high flags: A003
  11. -- rect: left=82 top=302 right=324 bottom=182
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: Install
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   if the optionkey is down then pass mouseup
  23.   put installres(XFCN,RenameFile) into it
  24.   if it is empty then play oops
  25.   else answer it
  26. end mouseUp
  27.  
  28.  
  29.  
  30. -- part 2 (button)
  31. -- low flags: 00
  32. -- high flags: A004
  33. -- rect: left=224 top=242 right=293 bottom=283
  34. -- title width / last selected line: 0
  35. -- icon id / first selected line: 27056 / 27056
  36. -- text alignment: 1
  37. -- font id: 0
  38. -- text size: 12
  39. -- style flags: 0
  40. -- line height: 16
  41. -- part name: Try It
  42. ----- HyperTalk script -----
  43. --
  44. --12/15/87  ‚Ä¢‚Ä¢‚Ä¢Steve Drazga‚Ä¢‚Ä¢‚Ä¢
  45. --
  46. --This script needs XFCNs 'FilenName' and 'RenameFile'
  47. --It also needs the Hypertalk function 'LastPathComponent'
  48. --It also needs the Hypertalk subroutine 'OsErr'
  49. --
  50. on mouseUp
  51.   if the optionkey is down then pass mouseup
  52.   put "Please select a file to rename"
  53.   put filename() into renamethis
  54.   if renamethis is empty then
  55.     hide message window
  56.     play oops
  57.     exit mouseup
  58.   end if
  59.   hide message window
  60.  
  61.   put LastPathComponent(renamethis) into shortname
  62.   ask "What do you want to name this file" with shortname
  63.   if it is shortname or it is empty then
  64.     hide message window
  65.     play oops
  66.     exit mouseup
  67.   end if
  68.  
  69.   put RenameFile(renamethis,it) into returnedthis
  70.  
  71.   if returnedthis = 0 then
  72.     answer "Everything went just fine"
  73.   else
  74.     if returnedthis < 0 then
  75.       OsErr returnedthis
  76.     else
  77.       play oops
  78.       answer "Whoops, there was an error"
  79.     end if
  80.   end if
  81. end mouseUp
  82.  
  83.  
  84.  
  85. -- part contents for background part 5
  86. ----- text -----
  87. RenameFile
  88.  
  89. -- part contents for background part 10
  90. ----- text -----
  91. 8
  92.  
  93. -- part contents for background part 6
  94. ----- text -----
  95.  
  96. This will change the name of a file.
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103. Thanks to:
  104. Dewi Williams
  105. 2227 Juniper Court
  106. Boulder CO 80302
  107. (303) 443 9038
  108. Delphi: DEWI
  109.  
  110.  
  111. -- part contents for background part 7
  112. ----- text -----
  113. Syntax:
  114.  
  115. RenameFile ("OldName",
  116. "NewName")
  117.  
  118. "OldName" is a full pathname of the file that you want to rename.
  119.  
  120. "NewName" is a replacement for the last component of the path.
  121.  
  122. Do not put quotation marks around 
  123. "OldName" and "NewName"
  124.  
  125. The result will contain either 
  126. 0 (meaning a successful operation),
  127. 1 (meaning a parameter error), or
  128. a negative number (representing an operating system error).
  129.  
  130. You can use the 'OsErr' function provided in the script of this stack to interpret operating system errors.